//
//  CanceOrderlViewController.m
//  LazyCat
//
//  Created by jike on 15/12/26.
//  Copyright (c) 2015年 zhanshu. All rights reserved.
//

#import "CanceOrderlViewController.h"

@interface CanceOrderlViewController ()<UITextViewDelegate,UIPickerViewDataSource,UIPickerViewDelegate>

@property (nonatomic,strong) UIButton *btn1;
@property (nonatomic,strong) UIButton *btn2;
@property (nonatomic,strong) UIButton *btn3;
@property (nonatomic,strong) UITextView *detailV;//textView
@property (nonatomic,strong) UIView *popView;
@property (nonatomic,strong) UIView *timeView;
@property (nonatomic,strong) UIPickerView *pickerView;
@property (nonatomic,strong) UITextField *timeTF;//textField
@property (nonatomic,strong) NSString *riqi;//收货日期
@property (nonatomic,strong) NSString *shijian;//收货时间
@property (nonatomic,strong) NSString *placeholderLabel;
@property (nonatomic,strong) NSMutableArray *dateArr;//时间数组
@property (nonatomic,strong) NSMutableDictionary *dicty;//字典
@property (nonatomic,strong) NSArray *firstArr;//第一个数组
@property (nonatomic,strong) NSArray *secondArr;//第二个数组

@end

@implementation CanceOrderlViewController
- (void)backAction:(UIButton *)btn {//判断是否可以HTML返回
    if ([self.tuisong isEqualToString:@"y"]) {
        [self dismissViewControllerAnimated:NO completion:^{
        }];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    if ([self.orderType isEqualToString:@"0"]) {
        [self initNav:@"取消订单" doBack:YES];
    }else {
        [self initNav:@"延时发货" doBack:YES];
    }
    if ([self.orderType isEqualToString:@"0"]) {
        self.placeholderLabel = @"请在此描述详细问题";
    }else {
        self.placeholderLabel = @"非常抱歉，您的订单由于缺货，我们将延时为您配送";
    }
    UIView *lineV1 = [[UIView alloc]initWithFrame:CGRectMake(0, 63, ScreenWidth, 1)];
    lineV1.backgroundColor = [UIColor lightGrayColor];
    lineV1.alpha = 0.2;
    [self.navBar addSubview:lineV1];
    self.view.backgroundColor = BackColor;
    //第一块
    UIView *orderNumV = [[UIView alloc]initWithFrame:CGRectMake(0, 84, ScreenWidth, 50)];
    orderNumV.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:orderNumV];
/*************************************************************/
    UILabel *labelName1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 60, 50)];
    labelName1.text = @"订单号:";
    labelName1.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
    labelName1.font = [UIFont systemFontOfSize:16];
    labelName1.textAlignment = NSTextAlignmentLeft;
    [orderNumV addSubview:labelName1];
    UILabel *labelNum = [[UILabel alloc]initWithFrame:CGRectMake(70, 0, ScreenWidth-70, 50)];
    labelNum.text = self.orderNumber;
    labelNum.textAlignment = NSTextAlignmentLeft;
    labelNum.font = [UIFont systemFontOfSize:16];
    labelNum.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
    [orderNumV addSubview:labelNum];
    /**************************************/
    UILabel *labelName2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 72, 50)];
    labelName2.text = @"收货时间:";
    labelName2.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
    labelName2.font = [UIFont systemFontOfSize:16];
    labelName2.textAlignment = NSTextAlignmentLeft;
    [orderNumV addSubview:labelName2];
    self.timeTF = [[UITextField alloc]initWithFrame:CGRectMake(82, 0, ScreenWidth-85, 50)];
    self.timeTF.placeholder = @"选择收货时间";
    self.timeTF.textAlignment = NSTextAlignmentLeft;
    self.timeTF.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
    self.timeTF.borderStyle = UITextBorderStyleNone;
    self.timeTF.font = [UIFont systemFontOfSize:16];
    [self.timeTF setEnabled:NO];
    [orderNumV addSubview:self.timeTF];
    if ([self.orderType isEqualToString:@"0"]) {
        labelName1.hidden = NO;
        labelNum.hidden = NO;
        labelName2.hidden = YES;
        self.timeTF.hidden = YES;
    }else {
        labelName1.hidden = YES;
        labelNum.hidden = YES;
        labelName2.hidden = NO;
        self.timeTF.hidden = NO;
        orderNumV.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(upAction)];
        [orderNumV addGestureRecognizer:tap];
    }
/*************************************************************/
    UIView *lineV2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 1)];
    lineV2.backgroundColor = [UIColor lightGrayColor];
    lineV2.alpha = 0.2;
    [orderNumV addSubview:lineV2];
    UIView *lineV3 = [[UIView alloc]initWithFrame:CGRectMake(0, 49, ScreenWidth, 1)];
    lineV3.backgroundColor = [UIColor lightGrayColor];
    lineV3.alpha = 0.2;
    [orderNumV addSubview:lineV3];
    //第二块
    UIView *reasonV = [[UIView alloc]initWithFrame:CGRectMake(0, 154, ScreenWidth, 210)];
    reasonV.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:reasonV];
    UIView *lineV4 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 1)];
    lineV4.backgroundColor = [UIColor lightGrayColor];
    lineV4.alpha = 0.2;
    [reasonV addSubview:lineV4];
    UIView *lineV5 = [[UIView alloc]initWithFrame:CGRectMake(0, 209, ScreenWidth, 1)];
    lineV5.backgroundColor = [UIColor lightGrayColor];
    lineV5.alpha = 0.2;
    [reasonV addSubview:lineV5];
    UILabel *label11 = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 120, 40)];
    if ([self.orderType isEqualToString:@"0"]) {
        label11.text = @"取消原因";
    }else {
        label11.text = @"延时发货原因";
    }
    label11.font = [UIFont systemFontOfSize:17];
    [reasonV addSubview:label11];
    self.btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btn1.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
    self.btn1.frame = CGRectMake(10, 45, (ScreenWidth-60)/3, 40);
    self.btn1.layer.cornerRadius = 5.0;
    self.btn1.layer.masksToBounds = YES;
    self.btn1.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.btn1 setTitle:@"缺货" forState:UIControlStateNormal];
    [self.btn1 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
    [reasonV addSubview:self.btn1];
    self.btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btn2.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
    self.btn2.frame = CGRectMake(30+(ScreenWidth-60)/3, 45, (ScreenWidth-60)/3, 40);
    self.btn2.layer.cornerRadius = 5.0;
    self.btn2.layer.masksToBounds = YES;
    self.btn2.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.btn2 setTitle:@"距离太远" forState:UIControlStateNormal];
    [self.btn2 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
    [reasonV addSubview:self.btn2];
    self.btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btn3.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
    self.btn3.frame = CGRectMake(50+2*(ScreenWidth-60)/3, 45, (ScreenWidth-60)/3, 40);
    self.btn3.layer.cornerRadius = 5.0;
    self.btn3.layer.masksToBounds = YES;
    self.btn3.titleLabel.font = [UIFont systemFontOfSize:16];
    [self.btn3 setTitle:@"天气原因" forState:UIControlStateNormal];
    [self.btn3 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
    [reasonV addSubview:self.btn3];
    if ([self.orderType isEqualToString:@"0"]) {
        self.btn1.hidden = NO;
        self.btn2.hidden = NO;
        self.btn3.hidden = NO;
        self.btn1.tag = 100;
        [self.btn1 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        self.btn2.tag = 200;
        [self.btn2 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        self.btn3.tag = 300;
        [self.btn3 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    }else {
        self.btn1.hidden = NO;
        self.btn2.hidden = YES;
        self.btn3.hidden = YES;
        self.btn1.backgroundColor = [UIColor colorWithRed:255/255.0 green:198/255.0 blue:0 alpha:1.0];
        [self.btn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.btn1.enabled = NO;
    }
    self.detailV = [[UITextView alloc]initWithFrame:CGRectMake(10, 110, ScreenWidth-20, 80)];
    self.detailV.text = @"请在此描述详细问题";
    self.detailV.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
    self.detailV.delegate = self;
    self.detailV.tag = 1;
    self.detailV.backgroundColor = [UIColor whiteColor];
    self.detailV.layer.cornerRadius = 5.0;
    self.detailV.font = [UIFont systemFontOfSize:16];
    self.detailV.layer.borderColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0].CGColor;
    self.detailV.layer.borderWidth = 2.0;
    self.detailV.layer.masksToBounds = YES;
    self.detailV.text = self.placeholderLabel;
    [reasonV addSubview:self.detailV];
 
    //第三行
    UIButton *qdBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qdBtn.frame = CGRectMake(15, 384, ScreenWidth-30, 45);
    qdBtn.layer.cornerRadius = 5.0;
    qdBtn.layer.masksToBounds = YES;
    qdBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    [qdBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    if ([self.orderType isEqualToString:@"0"]) {
        [qdBtn setTitle:@"确定" forState:UIControlStateNormal];
        [qdBtn addTarget:self action:@selector(quxiao) forControlEvents:UIControlEventTouchUpInside];
    }else {
        [qdBtn setTitle:@"延时发货" forState:UIControlStateNormal];
        [qdBtn addTarget:self action:@selector(ycfh) forControlEvents:UIControlEventTouchUpInside];
    }
    qdBtn.backgroundColor = [UIColor colorWithRed:255/255.0 green:198/255.0 blue:0 alpha:1.0];
    [self.view addSubview:qdBtn];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenKeyboard:)];
    //设置成NO表示当前控件响应后会传播到其他控件上，默认为YES。
    tap.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tap];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {//隐藏键盘
    [self.view endEditing:YES];
}
-(void)hiddenKeyboard:(UITapGestureRecognizer *)tap {//隐藏键盘
    [self.view endEditing:YES];
}
-(void)quxiao {//取消
    NSLog(@"============%@", self.detailV.text);
    NSString *url = [NSString stringWithFormat:quxiaoOrder,self.orderNumber,[AppData share].username,self.detailV.text];
    [NTNetUtil sendRequestWithUrl:url requestName:nil method:NTRequestMethodGET parameters:nil block:^(NTHttpRequest *networkRequest, NSError *error) {
        NSDictionary *dic = networkRequest.responseData;
        NSString *result = [dic objectForKey:@"m"];
        if ([result isEqualToString:@"success"]) {
            [self.delegate backStr:@"TTT"];
            [[MessShowView share]showWithMess:@"取消订单成功" login:YES];
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            [[MessShowView share]showWithMess:@"取消订单失败" login:NO];
        }
    }];
}
-(void)ycfh {//延迟发货
    NSString *url = [NSString stringWithFormat:delayOrderUrl,self.orderNumber,[AppData share].username,self.riqi,self.shijian,self.detailV.text];
    [NTNetUtil sendRequestWithUrl:url requestName:nil method:NTRequestMethodGET parameters:nil block:^(NTHttpRequest *networkRequest, NSError *error) {
        NSDictionary *dic = networkRequest.responseData;
        NSString *r = [dic objectForKey:@"r"];
        if ([r isEqualToString:@"T"]) {
            [self.delegate backStr:@"TT"];
            [[MessShowView share]showWithMess:@"延时发货成功" login:YES];
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            [[MessShowView share]showWithMess:@"延时发货失败" login:NO];
        }
    }];
}
-(void)upAction {//显示时间
    [self.view endEditing:YES];
    [self getTimeArr];//获取时间数组
    UIWindow *keyWindow=[UIApplication sharedApplication].keyWindow;
    self.popView=[[UIView alloc]initWithFrame:keyWindow.bounds];
    self.popView.backgroundColor=SetColor(0, 0, 0, .4);
    self.popView.alpha=0;
    [keyWindow addSubview:self.popView];
    [UIView animateWithDuration:0.2 animations:^{
        self.popView.alpha=1;
    }];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hidentPopView)];
    [self.popView addGestureRecognizer:tap];
    //添加时间view
    self.timeView = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight, ScreenWidth, 200)];
    self.timeView.backgroundColor = [UIColor whiteColor];
    [keyWindow addSubview:self.timeView];
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45)];
    backView.backgroundColor = BackColor;
    [self.timeView addSubview:backView];
    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    cancelBtn.frame = CGRectMake(0, 0, 60, 45);
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [cancelBtn addTarget:self action:@selector(hidentPopView) forControlEvents:UIControlEventTouchUpInside];
    cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [backView addSubview:cancelBtn];
    UILabel *label = [[UILabel alloc]init];
    label.text = @"选择收货时间";
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor darkGrayColor];
    label.font = [UIFont systemFontOfSize:14];
    label.frame = CGRectMake(60, 0, ScreenWidth-120, 45);
    [backView addSubview:label];
    UIButton *qdBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qdBtn.frame = CGRectMake(ScreenWidth-60, 0, 60, 45);
    [qdBtn setTitle:@"确定" forState:UIControlStateNormal];
    [qdBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [qdBtn addTarget:self action:@selector(clickSuccess) forControlEvents:UIControlEventTouchUpInside];
    qdBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [backView addSubview:qdBtn];
    self.pickerView = [[UIPickerView alloc]init];
    self.pickerView.frame = CGRectMake(0, 45, ScreenWidth, 155);
    self.pickerView.backgroundColor = BackColor;
    self.pickerView.delegate = self;
    [self.timeView addSubview:self.pickerView];
    CGPoint center = self.timeView.center;
    center.y = ScreenHeight-100;
    [UIView animateWithDuration:0.2 animations:^{
        self.timeView.center = center;
    }];
}
-(void)getTimeArr {//获取时间数组
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];//第一种格式
    self.dateArr = [NSMutableArray array];//日期数组
    NSString *stTime = [AppData share].openingstart;//开店时间
    NSString *enTime = [AppData share].openingend;//关店时间
    NSDateFormatter *formatter1 = [[NSDateFormatter alloc] init];
    [formatter1 setDateFormat:@"HH"];//第二种时间
    NSString *nowHour = [formatter1 stringFromDate:[NSDate date]];//当前时间
    NSInteger now = [nowHour integerValue];
    NSInteger st = [[stTime substringToIndex:2] integerValue];
    NSInteger en = [[enTime substringToIndex:2] integerValue];
    NSMutableArray *arr2 = [NSMutableArray array];
    if (now > en) {//这里只有六天
        for (int i = 1; i < 7; i++) {
            NSDate *tm = [[NSDate date] dateByAddingTimeInterval:(24*60*60)*(i)];
            NSString *shDate = @"";
            shDate = [formatter stringFromDate:tm];
            [self.dateArr addObject:shDate];//添加日期  这里是所有时间的数组
        }
    }else {//这里有七天
        for (int i = 0; i < 7; i++) {
            NSDate *tm = [[NSDate date] dateByAddingTimeInterval:(24*60*60)*(i)];
            NSString *shDate = @"";
            shDate = [formatter stringFromDate:tm];
            [self.dateArr addObject:shDate];//添加日期  这里是所有时间的数组
        }
    }
    if (st >= now) {//店铺开业时间大于当前时间
        for (NSInteger i = st; i < en; i++) {
            NSString *mm = [NSString stringWithFormat:@"%ld:00~",(long)i];
            NSString *nn = @"0";
            if (mm.length == 5) {
                mm = [nn stringByAppendingString:mm];
            }
            NSString *qq = [NSString stringWithFormat:@"%ld:00",(long)i+1];
            if (qq.length == 4) {
                qq = [nn stringByAppendingString:qq];
            }
            NSString *dd = [NSString stringWithFormat:@"%@%@",mm,qq];
            [arr2 addObject:dd];
        }
    }else if (now > st && now < en) {
        for (NSInteger i = now; i < en; i++) {
            NSString *mm = [NSString stringWithFormat:@"%ld:00~",(long)i];
            NSString *nn = @"0";
            if (mm.length == 5) {
                mm = [nn stringByAppendingString:mm];
            }
            NSString *qq = [NSString stringWithFormat:@"%ld:00",(long)i+1];
            if (qq.length == 4) {
                qq = [nn stringByAppendingString:qq];
            }
            NSString *dd = [NSString stringWithFormat:@"%@%@",mm,qq];
            [arr2 addObject:dd];
        }
    }else {
        for (NSInteger i = st; i < en; i++) {
            NSString *mm = [NSString stringWithFormat:@"%ld:00~",(long)i];
            NSString *nn = @"0";
            if (mm.length == 5) {
                mm = [nn stringByAppendingString:mm];
            }
            NSString *qq = [NSString stringWithFormat:@"%ld:00",(long)i+1];
            if (qq.length == 4) {
                qq = [nn stringByAppendingString:qq];
            }
            NSString *dd = [NSString stringWithFormat:@"%@%@",mm,qq];
            [arr2 addObject:dd];
        }
    }
    NSMutableArray *arr3 = [NSMutableArray array];
    for (NSInteger i = st; i < en; i++) {
        NSString *mm = [NSString stringWithFormat:@"%ld:00~",(long)i];
        NSString *nn = @"0";
        if (mm.length == 5) {
            mm = [nn stringByAppendingString:mm];
        }
        NSString *qq = [NSString stringWithFormat:@"%ld:00",(long)i+1];
        if (qq.length == 4) {
            qq = [nn stringByAppendingString:qq];
        }
        NSString *dd = [NSString stringWithFormat:@"%@%@",mm,qq];
        [arr3 addObject:dd];
    }
    self.dicty = [NSMutableDictionary dictionary];
    for (int i = 0; i < self.dateArr.count; i++) {
        if (i == 0) {
            NSString *tem = [NSString stringWithFormat:@"%@",self.dateArr[i]];
            [self.dicty setObject:arr2 forKey:tem];
        }else {
            NSString *tem = [NSString stringWithFormat:@"%@",self.dateArr[i]];
            [self.dicty setObject:arr3 forKey:tem];
        }
    }
    self.firstArr = self.dateArr;//第一个数组
    self.secondArr = arr2;
}
//pickerview代理
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 2;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    if (component == 0) {
        return self.firstArr.count;
    }else {
        return self.secondArr.count;
    }
}
-(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
    return 35;
}
-(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    if (component == 0) {
        return ScreenWidth/2+20;
    }else {
        return ScreenWidth/2-20;
    }
}
#pragma mark - 设置piker显示内容
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
    UILabel *myView = nil;
    if (component == 0) {
        myView = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 100, 30)];
        myView.textAlignment = NSTextAlignmentCenter;
        myView.text = [self.firstArr objectAtIndex:row];
        myView.font = [UIFont systemFontOfSize:14];         //用label来设置字体大小
        myView.backgroundColor = [UIColor clearColor];
    }else {
        myView = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 180, 30)];
        myView.text = [self.secondArr objectAtIndex:row];
        myView.textAlignment = NSTextAlignmentCenter;
        myView.font = [UIFont systemFontOfSize:14];
        myView.backgroundColor = [UIColor clearColor];
    }
    return myView;
}
//#pragma mark - pick滚动代理方法
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    //这里是联动的代码
    if (component == 0) {
        NSString *selectedCityName = self.firstArr[row];
        self.secondArr = [self.dicty valueForKey:selectedCityName];
        [pickerView reloadComponent:1];
        [pickerView selectRow:0 inComponent:1 animated:YES];
    }
    if (component == 1) {
        
    }
}
-(void)clickSuccess {//点击确定
    self.riqi = [self.firstArr objectAtIndex:[self.pickerView selectedRowInComponent:0]];//选择的日期
    self.shijian = [self.secondArr objectAtIndex:[self.pickerView selectedRowInComponent:1]];//选择的时间
    self.timeTF.text = [NSString stringWithFormat:@"%@ %@",self.riqi,self.shijian];
    CGPoint center = self.timeView.center;//隐藏视图
    center.y = ScreenHeight+100;
    [UIView animateWithDuration:0.2 animations:^{
        self.timeView.center = center;
        self.popView.alpha=0;
    }];
}
-(void)hidentPopView {//隐藏视图
    CGPoint center = self.timeView.center;
    center.y = ScreenHeight+100;
    [UIView animateWithDuration:0.2 animations:^{
        self.timeView.center = center;
        self.popView.alpha=0;
    }];
}
-(void)click:(UIButton *)sender {//点击按钮
    if (sender.tag == 100) {//点击缺货
        self.btn1.backgroundColor = [UIColor colorWithRed:255/255.0 green:198/255.0 blue:0 alpha:1.0];
        self.btn2.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
        self.btn3.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
        [self.btn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.btn2 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
        [self.btn3 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
        self.detailV.text = @"非常抱歉，您的订单由于缺货，我们将无法为您配送";
    }else if (sender.tag == 200) {//点击太远
        self.btn2.backgroundColor = [UIColor colorWithRed:255/255.0 green:198/255.0 blue:0 alpha:1.0];
        [self.btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.btn1.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
        self.btn3.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
        [self.btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.btn1 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
        [self.btn3 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
        self.detailV.text = @"非常抱歉，您的订单由于不在我们服务范围内，我们将无法发货";
    }else {//点击天气原因
        self.btn3.backgroundColor = [UIColor colorWithRed:255/255.0 green:198/255.0 blue:0 alpha:1.0];
        [self.btn3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.btn1.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
        self.btn2.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
        [self.btn3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.btn2 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
        [self.btn1 setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
        self.detailV.text = @"非常抱歉，您的订单由于天气原因，我们暂时无法为您服务";
    }
}
-(void)textViewDidBeginEditing:(UITextView *)textView {
    if (self.detailV.text.length < 12) {
       self.placeholderLabel = @"";
        self.detailV.text = self.placeholderLabel;
    }
}
-(void)textViewDidEndEditing:(UITextView *)textView {
    [textView endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end
